/**
 * @file judgeDaysInYearStr.c
 * @author your name (you@domain.com)
 * @brief 使用数组重新改写判断当前日期属于本年度的第几天
 * @version 0.1
 * @date 2022-11-23
 *
 * @copyright Copyright (c) 2022
 *
 */
#include <stdio.h>
struct date
{
    int year; //成员变量
    int month;
    int day;
};
struct date mydate; //注意结构体的变量的定义
int main()
{
    /**
     * @brief
     * 如果是处在平面中的一天
     * 1月 days = mydate.day+0
     * 2月 days = mydate.day + 31
     * 3月 days = mydate.day + 31+ 28
     * 4月 days = mydate.day + 59 + 31
     * 5月 days = mydate.day + 90 + 30
     * 6月 days = mydate.day + 120 + 31
     * 7月 days = mydate.day + 151 + 30
     * 8月 days = mydate.day + 181 + 31
     * 9月 days = mydate.day + 212 + 31
     * 10月 days = mydate.day +243 + 30
     * 11月 days = mydate.day +273 + 31
     * 12月 days = mydate.day + 304 +30
     * 如果mydate.year是闰年&&mydate.month>=3,days+=1;
     */
    int days = 0;
    int i;
    //使得月份和数组下标一一对应
    int day_tag[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    //读入数据
    printf("Input year,month and day: ");
    /*注意使用.操作符访问成员变量*/
    scanf("%d%d%d", &mydate.year, &mydate.month, &mydate.day);
    //加天数间隔
    for (i = 1; i < mydate.month; i++)
    {
        days = days + day_tag[i];
    }
    //再加上当前日期
    days = days + mydate.day;
    //加入闰年的判断机制
    if ((mydate.year % 4 == 0 && mydate.year % 100 != 0 && mydate.year % 400 == 0) && mydate.month >= 3)
    {
        days += 1;
    }
    //输出当前日期是一年中的第几天
    printf("\n%d/%d/%d是第%d天", mydate.year, mydate.month, mydate.day, days);
    return 0;
}